Advanced Ray Tracing Final Project

Photon Mapping

CS 87/287 - Computer Graphics
Fall 2025

Asya Ulger

F006BQ4

Motivation & Theme

Motivation Image

Motivational reference image showcasing complex light interactions through glass and liquid

My motivation for this project stems from the fascinating interplay of light with transparent materials and liquids. The reference image showcases beautiful caustic patterns created when light passes through glass containers filled with colored liquids, creating intricate patterns of focused and scattered light on surrounding surfaces.

This scene demonstrates several interesting physical phenomena:

Reproducing these effects required implementing photon mapping for caustics, properly handling rough dielectric surfaces, and applying advanced denoising techniques to produce clean, production-quality images.

Feature 1: Photon Mapping 8 Points

Implementation Overview

I implemented a complete photon mapping system capable of rendering both caustic and global illumination effects. The implementation follows the approach described in Henrik Wann Jensen's paper with several optimizations:

Validation Images

Problems Encountered

Problem 1: Photons Landing on Floor

Initial implementation had ~54% of caustic photons landing on the floor instead of near the glass objects, resulting in wasted computation and poor caustic quality.

Solution:

Implemented targeted photon emission by:

  • Positioning spotlight above the objects of interest
  • Using directional sampling toward the glass surfaces
  • Setting appropriate cone angle (30°) to focus photons
  • Result: >95% of photons now interact with glass objects

Problem 2: Noisy Caustics with Low Photon Counts

With only 1M photons, caustics appeared grainy and had visible artifacts.

Solution:

Increased photon count to 25M and implemented cone filter weighting (k=1.1) for smoother reconstruction. Combined with bilateral denoising in post-processing for production-quality results.

Key Parameters

Parameter Value Reasoning
Caustic Photons 25,000,000 High density for smooth, detailed caustics
Caustic Radius 0.010 Balance between detail and smoothness
Cone Filter k 1.1 Smooth reconstruction while preserving detail
Max Bounces 10 Capture multiple refractions through glass/liquid

Feature 2: Depth of Field 1 Point

Implementation Overview

Implemented physically-based depth of field by simulating a thin lens camera model. Camera rays are jittered on the aperture plane and directed through the focal plane to create realistic blur.

Validation Images

Key Parameters

While depth of field creates beautiful cinematic effects, I ultimately chose to use a pinhole camera (aperture = 0) for the final render to keep all caustic details sharp and clearly visible.

Feature 3: Hexagonal Aperture Blades 1 Points

Implementation Overview

Extended the depth of field implementation to support realistic camera aperture shapes. Implemented hexagonal aperture blade simulation that creates characteristic hexagonal bokeh patterns.

Validation Images

The hexagonal aperture creates realistic bokeh shapes matching real camera lenses with 6-blade apertures. Out-of-focus highlights take on the hexagonal shape of the aperture opening.

Feature 4: Simple Extra Emitter - Spotlight 1 Point

Implementation Overview

Implemented a directional spotlight emitter with cone-shaped emission profile. The spotlight supports:

Validation Images

The spotlight was crucial for efficient photon mapping - by directing photons toward the glass objects, I achieved 95%+ photon utilization compared to 46% with omnidirectional emission.

Key Parameters

Feature 5: Intel Open Image Denoise 2 Points

Implementation Overview

Integrated Intel's Open Image Denoise (OIDN) library for AI-powered denoising. OIDN uses deep learning models trained on thousands of rendered images to remove Monte Carlo noise while preserving important details.

External Library Used:

Intel Open Image Denoise (OIDN) - Version 2.x

  • Neural network-based denoising
  • Trained on physically-based renders
  • Preserves textures and sharp edges
  • Industry-standard tool (used in Blender, Unity, etc.)

Validation Images

Before Denoising
After Denoising

Problems Encountered

Problem: Memory Access Violations

Initial implementation crashed due to improper buffer management between Darts image format and OIDN's expected format.

Solution:

Used OIDN-managed buffers (oidn::BufferRef) instead of raw pointers. Properly copied data between Darts' Image3f format and OIDN's float buffers with correct stride and alignment.

Performance Impact

Configuration Render Time Quality
256 SPP (No Denoise) ~8 minutes Good
32 SPP + OIDN ~1 minute Excellent

OIDN enables 8x faster renders with better quality by reducing required samples per pixel.

Feature 6: Simple Extra BSDF - Rough Dielectric 2 Points

Implementation Overview

Implemented a microfacet-based rough dielectric BSDF using GGX distribution for realistic frosted/translucent glass effects. The implementation includes:

Validation Images

The rough dielectric BSDF was essential for creating the translucent/frosted appearance of the perfume bottle glass, which diffuses light while maintaining transparency.

Implementation Details

// GGX Distribution Function float D_GGX(Vec3f m, float alpha) { float alpha2 = alpha * alpha; float cos_theta = m.z; float denom = cos_theta * cos_theta * (alpha2 - 1) + 1; return alpha2 / (M_PI * denom * denom); } // Smith Masking-Shadowing float G_Smith(Vec3f wi, Vec3f wo, float alpha) { return G1(wi, alpha) * G1(wo, alpha); } // Importance Sampling Vec3f sampleGGX(float alpha, Vec2f uv) { float theta = atan(alpha * sqrt(uv.x) / sqrt(1 - uv.x)); float phi = 2 * M_PI * uv.y; return sphericalDirection(theta, phi); }

Feature 7: Bilateral Filter with Variance Estimation 2 Points

Implementation Overview

Implemented bilateral filtering with pixel variance estimation for high-quality denoising. The algorithm performs two independent renders with different random seeds and uses the variance between them to guide adaptive filtering.

Algorithm Steps

  1. Render Pass 1: Render entire image with random seed 0
  2. Render Pass 2: Render entire image with random seed 1
  3. Variance Estimation: Compute per-pixel variance: variance = (img1 - img2)² / 2
  4. Average Images: mean = (img1 + img2) / 2
  5. Bilateral Filter: Apply edge-preserving filter weighted by variance

Filter Parameters

Parameter Value Effect
Spatial Sigma 2.0 Controls spatial blur extent
Color Sigma 0.1 Preserves edges (lower = sharper)
Filter Radius 5 pixels Neighborhood size

Why This Over OIDN?

While OIDN is powerful, bilateral filtering offers:

For my final render, I combined both: OIDN for general noise reduction and bilateral filtering for caustic preservation.

Additional Features (Not Graded)

Adaptive Photon Radius

Implemented adaptive search radius that adjusts based on local photon density, ensuring consistent radiance estimates across the image.

Photon Visualization Modes

Added debug visualization modes to display:

Optimized KD-Tree Construction

Implemented efficient median-split KD-tree construction with spatial hashing for O(log n) photon queries even with 25M photons.

Final Submitted Image

Final Render

Final production render combining all implemented features

Render Specifications

960×540 Resolution
256 Samples/Pixel
25M Caustic Photons

Scene Description

The final scene depicts a vintage wooden cabinet with two glass containers: a water glass and a decorative perfume bottle filled with pink liquid. A warm spotlight positioned above the objects creates dramatic caustic patterns on the wall and table surface. The caustics show the characteristic focusing patterns created by refraction through curved glass surfaces and liquid interfaces. The perfume bottle uses rough dielectric shading to create a frosted, translucent appearance, while the water glass remains perfectly clear to showcase sharp caustic effects. Bilateral denoising combined with OIDN produces a clean, production-quality result while preserving all fine caustic detail.

Technical Highlights